<?php if($_SESSION['sid']!=1) Header("Location: //www.12301.cc");?>
<link rel="stylesheet" href="http://www.12301.cc/tpl/new_tpl/New_announce/css/announce.css" type="text/css" />
<link rel="stylesheet" href="http://www.12301.cc/css/common/www.12301.cc.global.css"/>
   <div class="rtWrap">
        <p class="title">发布升级公告</p>
        <ul class="conBox">
            <li class="list">
                <div>
                    <span class="lt">标题</span>
                    <input class="titleInp" type="text" />
                </div>
                
            </li>
            <li class="list">
                <div>
                    <span class="lt">正文</span>
                    <div class="setBox"><textarea id="detailInfo" name="" style="height:500px;" title="请输入"></textarea></div>
                </div>

            </li>
        </ul>
        <div class="iBox"> 
            <span class="list colorOrange sub" data="2">取消</span>
            <span class="list colorBlue sub" data="1">保存至草稿箱</span>
            <span class="list releaseBtn sub" data="0">发布</span>
        </div>
    </div>
<script type="text/javascript" src="http://www.12301.cc/tpl/channels_confd/js/global.js"></script>
<script type="text/javascript" src="http://www.12301.cc/ue/ueditor_config_mini.js"></script>
<script type="text/javascript" src="http://www.12301.cc/ue/ueditor.all.min.js"></script>
<script type="text/javascript" src="http://wx.12301.cc/public/js/common/ajax.js"></script>
<script type="text/javascript" src="http://wx.12301.cc/public/js/common/class.js"></script>
<script>
    $(document).ready(function(){ 
		function getQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if (r != null) return unescape(r[2]); return null;
		}
		var checkid = getQueryString("?");
		if(checkid){
			var data = {
				id : checkid,
				action : "edit"
			};
			PFT.Ajax({
				url : "/module/pft_announce/announce_add.php",
				//url : "admin/pppp.php",
				type : "POST",
				dataType : "json",
				data : data
			},function(res){

                    $(".titleInp").val(res.title);
                    $("#detailInfo").text(res.details);


				
			})
		}
		setTimeout(function () { 
			var ue;
			ue = UE.getEditor('detailInfo');
		}, 400);
	　　
		$(".sub").click(function(){
			var sta = $(this).attr("data");
			if(sta=="1"){
				var status = "1"; 
			}else{
				var status = "0";
			}
			if(sta=="2"){
				location.reload();
				return false;
			
			}
			var ue;
			ue = UE.getEditor('detailInfo');
			var txt_content = ue.getContent();
			var title = $(".titleInp").val();
			if(title==""){
				PFT_GLOBAL.U.Alert("fail",'<p style="width:240px">标题不能为空</p>');
				return false;
			}
			if(txt_content==""){
				PFT_GLOBAL.U.Alert("fail",'<p style="width:240px">正文不能为空</p>');
				return false;
			}
			if(!checkid){
				var data = {
						title : title,
						content :txt_content,
						action : "add",
						status : status            //0表示发布  1 草稿箱
				};
			
			}else{
				var data = {
					title : title,
					content :txt_content,
					action : "add",
					id : checkid,
					status : status            //0表示发布  1 草稿箱
				};
			}
			PFT.Ajax({
				url : "/module/pft_announce/announce_add.php",
				//url : "admin/pppp.php",
				type : "POST",
				dataType : "json",
				data : data
			},function(res){
				if(res.status=="success"){
					PFT_GLOBAL.U.Alert("success",'<p style="width:240px">'+res.msg+'</p>');
					setTimeout(function () { 
						location.href = "pft_announce.html";
					}, 500);
					
				
				}else{
					PFT_GLOBAL.U.Alert("fail",'<p style="width:240px">'+res.msg+'</p>');
				}
				
			})
		
		
		})
	}); 




</script>